home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 41.zip / BS1 part 41 / Lattice C v5.02 d4.adf / examples / debugger / status.cpr < prev    next >
Text File  |  1988-11-07  |  1KB  |  51 lines

  1. /* Show all CLI tasks */
  2. NULL = "00000000"x
  3.  
  4. dosbase   = findlib("dos.library")
  5. rootnode  = import(offset(dosbase,34),4)
  6. tasktable = d2c(c2d(import(rootnode,4))*4,4)
  7. taskcount = c2d(import(tasktable,4))
  8. do tasknum = 1 to taskcount
  9.    proc = import(offset(tasktable,tasknum*4),4)
  10.    if (proc ~= NULL) then
  11.       do
  12.       proc = offset(proc,-92)
  13.       cli = d2c(c2d(import(offset(proc,172),4))*4,4)
  14.       command = 'No command loaded'
  15.       args = ''
  16.       if (cli ~= NULL) then
  17.          do
  18.          cmdname = d2c(c2d(import(offset(cli,16),4))*4,4)
  19.          cmdlen = c2d(import(cmdname, 1))
  20.          if cmdlen ~= 0 then
  21.             do
  22.             command = 'Command:' import(offset(cmdname,1), cmdlen)
  23.             cis = d2c(c2d(import(offset(cli,32),4))*4,4)
  24.             cptr = d2c(c2d(import(offset(cis,12),4))*4,4)
  25.             args = import(cptr,80)
  26.             args = translate(args,"'"||'0a0a'x,'"'||'0d00'x)
  27.             y = pos('0a'x, args)
  28.             if (y ~= 0) then args = left(args,y-1)
  29.             end
  30.          end
  31.       'd "Process' tasknum||': 0x'||c2x(proc) command args'"'
  32.       end
  33. end
  34. exit(0)
  35.  
  36. /* Find a given library in the system */
  37. findlib:
  38. parse arg tofind
  39. execbase = import("00000004"x,4)
  40. liboff = 378
  41. nodebase = import(offset(execbase, liboff), 4)
  42.  
  43. do while(import(nodebase,4) ~= NULL)
  44.    namestr = import(import(offset(nodebase,10),4))
  45.    if namestr = tofind then return nodebase
  46.    nodebase = import(nodebase,4)
  47. end
  48.  
  49. 'd "Could not find' tofind||'"'
  50. exit(0)
  51.